Array.prototype.remove=function(s){
		for(i=0;i<this .length;i++){
			if(s==this[i]) this.splice(i, 1);
		}
	}

edit_img= new Image(22,22); 
edit_img.src="../images/edit.png"; 

del_img= new Image(22,22); 
del_img.src="../images/delete.png"; 

//lee el xml para el autocompleter
function ajaxReadXML( xmlResponse , divDestino , tagName, idtf, att){

function showXML(xmlHttpRequest, responseHeader) {
	var arrayAutocomplete = new Array();
	var contador = xmlResponse.getElementsByTagName(tagName).length;
	
	if(att=="")	
	{	
		for (var i = 0; i < contador-1; i++)
			{
				arrayAutocomplete.push(xmlResponse.getElementsByTagName(tagName)[i].firstChild.data);
				
			}
			
			new Autocompleter.Local(idtf,divDestino, arrayAutocomplete, {});
	}
	else
	{	
		for (var i = 0; i < contador-1; i++)
			{
				arrayAutocomplete.push(xmlResponse.getElementsByTagName(tagName)[i].getAttribute(att));
				
			}
			
			new Autocompleter.Local(idtf,divDestino, arrayAutocomplete, {});
		
		}
		
	}
}


//funcion para leer el horario de cada estudiante
function ajaxReadSchedule(){

//		var pars = "";

		var ajaxRequest = new Ajax.Request('xml/student-course.xml', {
			method:       'get', 
			asynchronous: true,
			on404: show404, /* Error: Not Found */
			on408: show408, /* Error: Request Timeout */
			on500: show500, /* Error: Internal Server Error */
			on503: show503, /* Error: Service Unavailable due to overload or maintenance*/ 
			onFailure: showFailure,
			onException: showException,
			onSuccess: showXMLSchedule
		});
		
		function show404(xmlHttpRequest, responseHeader){
			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

		function show408(xmlHttpRequest, responseHeader){
			alert('Error 408: location "' + xmlHttpRequest.statusText + '" Request Timeout.');
		}

		function show500(xmlHttpRequest, responseHeader){
			alert('Error 500: location "' + xmlHttpRequest.statusText + '"Internal Server Error.');
		}

		function show503(xmlHttpRequest, responseHeader){
			alert('Error 503: location "' + xmlHttpRequest.statusText + '" Service Unavailable due to overload or maintenance.');
		}

		function showFailure(xmlHttpRequest, responseHeader){
			alert('Error ' + xmlHttpRequest.status + ' -- ' + xmlHttpRequest.statusText);
		}

		function showException(xmlHttpRequest, responseHeader){
//			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

function showXMLSchedule(xmlHttpRequest, responseHeader) {
	doc = xmlHttpRequest.responseXML;
	var Schedule="";
	
		Schedule ="<br><strong>" + doc.getElementsByTagName('student')[0].firstChild.data+ "</strong>";
		
		Schedule += "<br><br><table><tr><td width='250px'><strong>Nombre de la clase</strong></td><td><strong>Dias</strong></td><td><strong>Horario</strong></td><td><strong>Salon</strong></td><td><strong>Profesor</strong></td><tr>";
		
		var contador = doc.getElementsByTagName('course').length;
		
		for (var i=0;i<=contador-1;i++)
			{	
				Schedule += "<tr>";
				Schedule += "<td>";
				Schedule += doc.getElementsByTagName('course')[i].firstChild.data;
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('days');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('time');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('classroom');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('professor-name');
				Schedule += "</td>";
				Schedule += "</tr>";
				
			};
		
		Schedule += "</table>";
			document.getElementById('student_schedule_div').innerHTML = Schedule;
	}
}

//funcion que lee classroom-courses.xml
function ajaxReadClassroom(){

//		var pars = "";

		var ajaxRequest = new Ajax.Request('xml/classroom-courses.xml', {
			method:       'get', 
			asynchronous: true,
			on404: show404, /* Error: Not Found */
			on408: show408, /* Error: Request Timeout */
			on500: show500, /* Error: Internal Server Error */
			on503: show503, /* Error: Service Unavailable due to overload or maintenance*/ 
			onFailure: showFailure,
			onException: showException,
			onSuccess: showXMLClassroom
		});
		
		function show404(xmlHttpRequest, responseHeader){
			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

		function show408(xmlHttpRequest, responseHeader){
			alert('Error 408: location "' + xmlHttpRequest.statusText + '" Request Timeout.');
		}

		function show500(xmlHttpRequest, responseHeader){
			alert('Error 500: location "' + xmlHttpRequest.statusText + '"Internal Server Error.');
		}

		function show503(xmlHttpRequest, responseHeader){
			alert('Error 503: location "' + xmlHttpRequest.statusText + '" Service Unavailable due to overload or maintenance.');
		}

		function showFailure(xmlHttpRequest, responseHeader){
			alert('Error ' + xmlHttpRequest.status + ' -- ' + xmlHttpRequest.statusText);
		}

		function showException(xmlHttpRequest, responseHeader){
//			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

function showXMLClassroom(xmlHttpRequest, responseHeader) {
	doc = xmlHttpRequest.responseXML;
	var Schedule="";
	
		Schedule ="<br><p>Results</p><br><strong>" + doc.getElementsByTagName('classroom')[0].firstChild.data+ "</strong>";
		
		Schedule += "<br><br><table><tr><td width='250px'><strong>Course Name</strong></td><td><strong>Days</strong></td><td><strong>Time</strong></td><td><strong>Professor</strong></td><tr>";
		
		var contador = doc.getElementsByTagName('course').length;
		
		for (var i=0;i<=contador-1;i++)
			{	
				Schedule += "<tr>";
				Schedule += "<td>";
				Schedule += doc.getElementsByTagName('course')[i].firstChild.data;
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('days');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('time');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('professor-name');
				Schedule += "</td>";
				Schedule += "</tr>";
				
			};
		
		Schedule += "</table>";
			document.getElementById('classroom_results').innerHTML = Schedule;
	}
}

//funcion que lee classroom-courses.xml
function ajaxReadProfessor(){

//		var pars = "";

		var ajaxRequest = new Ajax.Request('xml/classroom-courses.xml', {
			method:       'get', 
			asynchronous: true,
			on404: show404, /* Error: Not Found */
			on408: show408, /* Error: Request Timeout */
			on500: show500, /* Error: Internal Server Error */
			on503: show503, /* Error: Service Unavailable due to overload or maintenance*/ 
			onFailure: showFailure,
			onException: showException,
			onSuccess: showXMLprofessor
		});
		
		function show404(xmlHttpRequest, responseHeader){
			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

		function show408(xmlHttpRequest, responseHeader){
			alert('Error 408: location "' + xmlHttpRequest.statusText + '" Request Timeout.');
		}

		function show500(xmlHttpRequest, responseHeader){
			alert('Error 500: location "' + xmlHttpRequest.statusText + '"Internal Server Error.');
		}

		function show503(xmlHttpRequest, responseHeader){
			alert('Error 503: location "' + xmlHttpRequest.statusText + '" Service Unavailable due to overload or maintenance.');
		}

		function showFailure(xmlHttpRequest, responseHeader){
			alert('Error ' + xmlHttpRequest.status + ' -- ' + xmlHttpRequest.statusText);
		}

		function showException(xmlHttpRequest, responseHeader){
//			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

function showXMLProfessor(xmlHttpRequest, responseHeader) {
	doc = xmlHttpRequest.responseXML;
	var Schedule="";
	
		Schedule ="<br><p>Results</p><br><strong>";
		
		Schedule += "<br><br><table><tr><td width='250px'><strong>Course Name</strong></td><td><strong>Days</strong></td><td><strong>Time</strong></td><td><strong>Professor</strong></td><tr>";
		
		var contador = doc.getElementsByTagName('course').length;
		
		for (var i=0;i<=contador-1;i++)
			{	
				Schedule += "<tr>";
				Schedule += "<td>";
				Schedule += doc.getElementsByTagName('course')[i].firstChild.data;
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('days');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('time');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('professor-name');
				Schedule += "</td>";
				Schedule += "</tr>";
				
			};
		
		Schedule += "</table>";
			document.getElementById('classroom_results').innerHTML = Schedule;
	}
}

//funcion que lee professor-courses.xml
function ajaxReadProfessor2(){

//		var pars = "";

		var ajaxRequest = new Ajax.Request('xml/professor-course.xml', {
			method:       'get', 
			asynchronous: true,
			on404: show404, /* Error: Not Found */
			on408: show408, /* Error: Request Timeout */
			on500: show500, /* Error: Internal Server Error */
			on503: show503, /* Error: Service Unavailable due to overload or maintenance*/ 
			onFailure: showFailure,
			onException: showException,
			onSuccess: showXMLProfessor2
		});
		
		function show404(xmlHttpRequest, responseHeader){
			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

		function show408(xmlHttpRequest, responseHeader){
			alert('Error 408: location "' + xmlHttpRequest.statusText + '" Request Timeout.');
		}

		function show500(xmlHttpRequest, responseHeader){
			alert('Error 500: location "' + xmlHttpRequest.statusText + '"Internal Server Error.');
		}

		function show503(xmlHttpRequest, responseHeader){
			alert('Error 503: location "' + xmlHttpRequest.statusText + '" Service Unavailable due to overload or maintenance.');
		}

		function showFailure(xmlHttpRequest, responseHeader){
			alert('Error ' + xmlHttpRequest.status + ' -- ' + xmlHttpRequest.statusText);
		}

		function showException(xmlHttpRequest, responseHeader){
//			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

function showXMLProfessor2(xmlHttpRequest, responseHeader) {
	doc = xmlHttpRequest.responseXML;
	var Schedule="";
	
		Schedule ="<br><p>Results</p><br><strong>" + doc.getElementsByTagName('professor')[0].firstChild.data+ "</strong>";
		
		Schedule += "<br><br><table><tr><td width='250px'><strong>Course Name</strong></td><td><strong>Days</strong></td><td><strong>Time</strong></td><td><strong>Classroom</strong></td><tr>";
		
		var contador = doc.getElementsByTagName('course').length;
		
		for (var i=0;i<=contador-1;i++)
			{	
				Schedule += "<tr>";
				Schedule += "<td>";
				Schedule += doc.getElementsByTagName('course')[i].firstChild.data;
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('days');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('time');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('classroom');
				Schedule += "</td>";
				Schedule += "</tr>";
				
			};
		
		Schedule += "</table>";
			document.getElementById('professor_results').innerHTML = Schedule;
	}
}


//funcion que muestra la lista de cursos disponibles
function ajaxReadAvCourses(){

//		var pars = "";

		var ajaxRequest = new Ajax.Request('xml/courses.xml', {
			method:       'get', 
			asynchronous: true,
			on404: show404, /* Error: Not Found */
			on408: show408, /* Error: Request Timeout */
			on500: show500, /* Error: Internal Server Error */
			on503: show503, /* Error: Service Unavailable due to overload or maintenance*/ 
			onFailure: showFailure,
			onException: showException,
			onSuccess: showXMLAvCourses
		});
		
		function show404(xmlHttpRequest, responseHeader){
			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

		function show408(xmlHttpRequest, responseHeader){
			alert('Error 408: location "' + xmlHttpRequest.statusText + '" Request Timeout.');
		}

		function show500(xmlHttpRequest, responseHeader){
			alert('Error 500: location "' + xmlHttpRequest.statusText + '"Internal Server Error.');
		}

		function show503(xmlHttpRequest, responseHeader){
			alert('Error 503: location "' + xmlHttpRequest.statusText + '" Service Unavailable due to overload or maintenance.');
		}

		function showFailure(xmlHttpRequest, responseHeader){
			alert('Error ' + xmlHttpRequest.status + ' -- ' + xmlHttpRequest.statusText);
		}

		function showException(xmlHttpRequest, responseHeader){
//			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

function showXMLAvCourses(xmlHttpRequest, responseHeader) {
	doc = xmlHttpRequest.responseXML;
	var Schedule="";
		
		Schedule += "<br><br><div style=\"width:250px;float:left;\"><strong>Course Name</strong></div><div style=\"width:100px;float:left;\"><strong>Days</strong></div><div style=\"width:100px;float:left;\"><strong>Time</strong></div><div style=\"width:100px;float:left;\"><strong>Classroom</strong></div><div style=\"width:120px;float:left;\"><strong>Professor</strong></div><div style=\"width:100px;float:left;\"></div><br><br>";
		
		var contador = doc.getElementsByTagName('course').length;
		
		for (var i=0;i<=contador-1;i++)
			{	
				Schedule += "<div id='"+ doc.getElementsByTagName('course')[i].firstChild.data +"'>"
				Schedule += "<div style=\"width:250px;float:left;\" >";
				Schedule += doc.getElementsByTagName('course')[i].firstChild.data;
				Schedule += "</div>";
				Schedule += "<div style=\"width:100px;float:left;\" >";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('days');
				Schedule += "</div>";
				Schedule += "<div style=\"width:100px;float:left;\" >";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('time');
				Schedule += "</div>";
				Schedule += "<div style=\"width:100px;float:left;\" >";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('classroom');
				Schedule += "</div>";
				Schedule += "<div style=\"width:120px;float:left;\" >";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('professor_name');
				Schedule += "</div>";
				Schedule += "<div style=\"width:100px;float:left;\" >";
				Schedule += "<a href='javascript:;' onclick=\"inscribir('";
				Schedule += doc.getElementsByTagName('course')[i].firstChild.data;
				Schedule += "','" + doc.getElementsByTagName('course')[i].getAttribute('days');
				Schedule += "','" + doc.getElementsByTagName('course')[i].getAttribute('time');
				Schedule += "','" + doc.getElementsByTagName('course')[i].getAttribute('classroom');
				Schedule += "','" + doc.getElementsByTagName('course')[i].getAttribute('professor_name');
				Schedule += "'),new Effect.SwitchOff('"+ doc.getElementsByTagName('course')[i].firstChild.data +"');\">inscribir</a>";
				Schedule += "</div></div><br>";
			}
		
			document.getElementById('courses_list').innerHTML = Schedule;
	}
}
	
//funcion que lee la lista de alumnos para poder modificar y borrar
function ajaxReadModStud(){

//		var pars = "";

		var ajaxRequest = new Ajax.Request('xml/students.xml', {
			method:       'get', 
			asynchronous: true,
			on404: show404, /* Error: Not Found */
			on408: show408, /* Error: Request Timeout */
			on500: show500, /* Error: Internal Server Error */
			on503: show503, /* Error: Service Unavailable due to overload or maintenance*/ 
			onFailure: showFailure,
			onException: showException,
			onSuccess: showXMLModStud
		});
		
		function show404(xmlHttpRequest, responseHeader){
			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

		function show408(xmlHttpRequest, responseHeader){
			alert('Error 408: location "' + xmlHttpRequest.statusText + '" Request Timeout.');
		}

		function show500(xmlHttpRequest, responseHeader){
			alert('Error 500: location "' + xmlHttpRequest.statusText + '"Internal Server Error.');
		}

		function show503(xmlHttpRequest, responseHeader){
			alert('Error 503: location "' + xmlHttpRequest.statusText + '" Service Unavailable due to overload or maintenance.');
		}

		function showFailure(xmlHttpRequest, responseHeader){
			alert('Error ' + xmlHttpRequest.status + ' -- ' + xmlHttpRequest.statusText);
		}

		function showException(xmlHttpRequest, responseHeader){
//			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

function showXMLModStud(xmlHttpRequest, responseHeader) {
	doc = xmlHttpRequest.responseXML;
	var Schedule="";
		
		Schedule += "<table width='800px'><tr><td width='100px'><strong>Student ID</strong></td><td width='250px'><strong>Student Name</strong></td><td width='50px'></td><td width='50px'></td><tr>";
		
		var contador = doc.getElementsByTagName('person').length;
		
		for (var i=0;i<=contador-1;i++)
			{	
				Schedule += "<tr>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('person')[i].getAttribute('id');
				Schedule += "</td>";
				Schedule += "<td width='250px'>";
				Schedule +=  doc.getElementsByTagName('person')[i].firstChild.data;
				Schedule += "</td>";
				Schedule += "<td width='50px'>";
				Schedule += "<img src='images/edit.png' width='22' height='22' onclick=\"edit('"+ doc.getElementsByTagName('person')[i].getAttribute('id') +"_edit_form','students')\">";
				Schedule += "</td>";
				Schedule += "<td width='50px'>";
				Schedule += "<img src='images/delete.png' width='22' height='22'>";
				Schedule += "</td><tr>";
				Schedule += "<td colspan='4'>";
				Schedule += "<div id='"+ doc.getElementsByTagName('person')[i].getAttribute('id') + "_edit_form'></div>";
				Schedule += "</td></tr>";
			};
		
		Schedule += "</table><br>";
			document.getElementById('list_st_div').innerHTML = Schedule;
			Effect.toggle('list_st_div','blind')

	}
}

//funcion que lee la lista de profesores para poder modificar y borrar
function ajaxReadModProf(){

//		var pars = "";

		var ajaxRequest = new Ajax.Request('xml/professors.xml', {
			method:       'get', 
			asynchronous: true,
			on404: show404, /* Error: Not Found */
			on408: show408, /* Error: Request Timeout */
			on500: show500, /* Error: Internal Server Error */
			on503: show503, /* Error: Service Unavailable due to overload or maintenance*/ 
			onFailure: showFailure,
			onException: showException,
			onSuccess: showXMLModProf
		});
		
		function show404(xmlHttpRequest, responseHeader){
			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

		function show408(xmlHttpRequest, responseHeader){
			alert('Error 408: location "' + xmlHttpRequest.statusText + '" Request Timeout.');
		}

		function show500(xmlHttpRequest, responseHeader){
			alert('Error 500: location "' + xmlHttpRequest.statusText + '"Internal Server Error.');
		}

		function show503(xmlHttpRequest, responseHeader){
			alert('Error 503: location "' + xmlHttpRequest.statusText + '" Service Unavailable due to overload or maintenance.');
		}

		function showFailure(xmlHttpRequest, responseHeader){
			alert('Error ' + xmlHttpRequest.status + ' -- ' + xmlHttpRequest.statusText);
		}

		function showException(xmlHttpRequest, responseHeader){
//			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

function showXMLModProf(xmlHttpRequest, responseHeader) {
	doc = xmlHttpRequest.responseXML;
	var Schedule="";
		
		Schedule += "<table width='800px'><tr><td width='250px'><strong>Professor Name</strong></td><td width='50px'></td><td width='50px'></td>";
		
		var contador = doc.getElementsByTagName('person').length;
		
		for (var i=0;i<=contador-1;i++)
			{	
				Schedule += "<tr>";
				Schedule += "<td width='250px'>";
				Schedule += doc.getElementsByTagName('person')[i].firstChild.data;
				Schedule += "</td>";
				Schedule += "<td width='50px'>";
				Schedule += "<img src='images/edit.png' width='22' height='22' onclick=\"edit('"+ doc.getElementsByTagName('person')[i].getAttribute('id') +"_edit_form','professors')\">";
				Schedule += "</td>";
				Schedule += "<td width='50px'>";
				Schedule += "<img src='images/delete.png' width='22' height='22'>";
				Schedule += "</td><tr>";
				Schedule += "<td colspan='4'>";
				Schedule += "<div id='"+ doc.getElementsByTagName('person')[i].getAttribute('id') + "_edit_form'></div>";
				Schedule += "</td></tr>";	
			};
		
		Schedule += "</table><br>";
			document.getElementById('list_teacher_div').innerHTML = Schedule;
			Effect.toggle('list_teacher_div','blind')
	}
}

//funcion que lee la lista de cursos para poder modificar y borrar
function ajaxReadModCourses(){

//		var pars = "";

		var ajaxRequest = new Ajax.Request('xml/courses.xml', {
			method:       'get', 
			asynchronous: true,
			on404: show404, /* Error: Not Found */
			on408: show408, /* Error: Request Timeout */
			on500: show500, /* Error: Internal Server Error */
			on503: show503, /* Error: Service Unavailable due to overload or maintenance*/ 
			onFailure: showFailure,
			onException: showException,
			onSuccess: showXMLModCourses
		});
		
		function show404(xmlHttpRequest, responseHeader){
			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

		function show408(xmlHttpRequest, responseHeader){
			alert('Error 408: location "' + xmlHttpRequest.statusText + '" Request Timeout.');
		}

		function show500(xmlHttpRequest, responseHeader){
			alert('Error 500: location "' + xmlHttpRequest.statusText + '"Internal Server Error.');
		}

		function show503(xmlHttpRequest, responseHeader){
			alert('Error 503: location "' + xmlHttpRequest.statusText + '" Service Unavailable due to overload or maintenance.');
		}

		function showFailure(xmlHttpRequest, responseHeader){
			alert('Error ' + xmlHttpRequest.status + ' -- ' + xmlHttpRequest.statusText);
		}

		function showException(xmlHttpRequest, responseHeader){
//			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

function showXMLModCourses(xmlHttpRequest, responseHeader) {
	doc = xmlHttpRequest.responseXML;
	var Schedule="";
		
		Schedule += "<table><tr><td width='250px'><strong>Course Name</strong></td><td width='100px'><strong>Time</strong></td><td width='100px'><strong>Days</strong></td><td width='100px'><strong>Classroom</strong></td><td width='150px'><strong>Professor</strong></td><td width='50px'></td><td width='50px'></td>";
		
		var contador = doc.getElementsByTagName('course').length;
		
		for (var i=0;i<=contador-1;i++)
			{	
				Schedule += "<tr>";
				Schedule += "<td>";
				Schedule += doc.getElementsByTagName('course')[i].firstChild.data;
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('time');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('days');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('classroom');
				Schedule += "</td>";
				Schedule += "<td width='100px'>";
				Schedule += doc.getElementsByTagName('course')[i].getAttribute('professor_name');
				Schedule += "</td>";
				Schedule += "<td width='50px'>";
				Schedule += "<img src='images/edit.png' width='22' height='22' onclick=\"edit('"+ doc.getElementsByTagName('course')[i].getAttribute('id') +"_edit_form','courses')\">";
				Schedule += "</td>";
				Schedule += "<td width='50px'>";
				Schedule += "<img src='images/delete.png' width='22' height='22'>";
				Schedule += "</td><tr>";
				Schedule += "<td colspan='7'>";
				Schedule += "<div id='"+ doc.getElementsByTagName('course')[i].getAttribute('id') + "_edit_form'></div>";
				Schedule += "</td></tr>";
			};
		
		
		
		Schedule += "</table><br>";
		
			document.getElementById('list_course_div').innerHTML = Schedule;
			Effect.toggle('list_course_div','blind');
	}
}

//funcion que lee la lista de salones para poder modificar y borrar
function ajaxReadModClass(){

//		var pars = "";

		var ajaxRequest = new Ajax.Request('xml/classrooms.xml', {
			method:       'get', 
			asynchronous: true,
			on404: show404, /* Error: Not Found */
			on408: show408, /* Error: Request Timeout */
			on500: show500, /* Error: Internal Server Error */
			on503: show503, /* Error: Service Unavailable due to overload or maintenance*/ 
			onFailure: showFailure,
			onException: showException,
			onSuccess: showXMLModClass
		});
		
		function show404(xmlHttpRequest, responseHeader){
			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

		function show408(xmlHttpRequest, responseHeader){
			alert('Error 408: location "' + xmlHttpRequest.statusText + '" Request Timeout.');
		}

		function show500(xmlHttpRequest, responseHeader){
			alert('Error 500: location "' + xmlHttpRequest.statusText + '"Internal Server Error.');
		}

		function show503(xmlHttpRequest, responseHeader){
			alert('Error 503: location "' + xmlHttpRequest.statusText + '" Service Unavailable due to overload or maintenance.');
		}

		function showFailure(xmlHttpRequest, responseHeader){
			alert('Error ' + xmlHttpRequest.status + ' -- ' + xmlHttpRequest.statusText);
		}

		function showException(xmlHttpRequest, responseHeader){
//			alert('Error 404: location "' + xmlHttpRequest.statusText + '" was not found.');
		}

function showXMLModClass(xmlHttpRequest, responseHeader) {
	doc = xmlHttpRequest.responseXML;
	var Schedule="";
		
		Schedule += "<table width='800'><tr><td width='250px'><strong>ClassRoom</strong></td><td width='50px'></td><td width='50px'></td>";
		
		var contador = doc.getElementsByTagName('classroom').length;
		
		for (var i=0;i<=contador-1;i++)
			{	
				Schedule += "<tr>";
				Schedule += "<td width='250px'>";
				Schedule += doc.getElementsByTagName('classroom')[i].firstChild.data;
				Schedule += "</td>";
				Schedule += "<td width='50px'>";
				Schedule += "<img src='images/edit.png' width='22' height='22' onclick=\"edit('"+ doc.getElementsByTagName('classroom')[i].getAttribute('id') +"_edit_form','class')\">";
				Schedule += "</td>";
				Schedule += "<td width='50px'>";
				Schedule += "<img src='images/delete.png' width='22' height='22'>";
				Schedule += "</td><tr>";
				Schedule += "<td colspan='3'>";
				Schedule += "<div id='"+ doc.getElementsByTagName('classroom')[i].getAttribute('id') + "_edit_form'></div>";
				Schedule += "</td></tr>";	
			};
		
		Schedule += "</table><br>";
			document.getElementById('list_class_div').innerHTML = Schedule;
			Effect.toggle('list_class_div','blind');
	}
}


function edit(element,element2, id)
{ 	
	var form="";
	
	if(element2=="students")
	{
		 form = "<div id=\"add_st_form\" style=\"width:800px;\"><form id=\"update_student_form\" name=\"update_student_form\" method=\"post\" action=\"\"><FIELDSET><LEGEND>Student form</LEGEND><label><br />ID:<input type=\"text\" id=\"sid\" class=\"tfield\"/></label><p><label>Name:<input type=\"text\" id=\"sname\" class=\"tfield\" /></label><label>Last Name:<input type=\"text\" id=\"sfirstLastName\" class=\"tfield\"/></label><label><input type=\"text\" id=\"ssecondLastName\" class=\"tfield\"/></label></p><p><label><input type=\"button\" name=\"Submit\" value=\"Submit\" onclick=\"updateStudent();\"/></label></p><p><div id=\"modifyStudentMessage\" style=\"position:absolut;top:200px;left:300px;width:500px\"></div></p><p>&nbsp;</p></FIELDSET></form></div>";
	}
	
	if(element2=="professors")
		{
			form = "<div id=\"add_teacher_form\" style=\"width:800px;\" ><form id=\"update_professor_form\" name=\"update_professor_form\" method=\"post\" action=\"\"><FIELDSET><LEGEND>Professor form</LEGEND><p><label>ID:<input type=\"text\" id=\"pid\" class=\"tfield\" /></label><br \><br \><label>Name:<input type=\"text\" id=\"pname\" class=\"tfield\" /></label><label> Last Name:<input type=\"text\" id=\"pfirstLastName\" class=\"tfield\"/></label><label><input type=\"text\" id=\"psecondLastName\" class=\"tfield\"/></label></p><p><label><input type=\"button\" name=\"Submit\" value=\"Submit\" onclick=\"updateProfessor();\"/></label></p><p><div id=\"modifyProfessorMessage\" style=\"position:absolut;top:200px;left:300px;width:500px\"></div></p><p>&nbsp;</p></FIELDSET></form></div>";
				
		}
		
	if(element2=="courses")
		{
			form = "<div id=\"add_course_form\" style=\"width:800px;\" ><form id=\"update_course_form\" name=\"update_course_form\" method=\"post\" action=\"\"><FIELDSET><LEGEND>Course form</LEGEND><label><br />Course Code:<input type=\"text\" id=\"code\" class=\"tfield\"/></label><p><label>Course Name:<input type=\"text\" id=\"name\" class=\"tfield\"/></label></p><p><label>Teacher's Name:<select id=\"professor\" class=\"tfield\"></select></label><label>Classroom course:<select id=\"classroom\" class=\"tfield\"></select></label></p><p>Schedule:</p><p><label>Days:<input id=\"days\" type=\"text\" size=\"10\" class=\"tfield\"/></label>(LMV/Ma J/LM/M) </p><p><label>Hour:<input id=\"shour\" type=\"text\" size=\"5\" class=\"tfield\"/></label>-<label><input id=\"ehour\" type=\"text\" size=\"5\" class=\"tfield\"/></label>(start hour-finish hour / hh:mm) </p><p><label><input type=\"button\" name=\"Submit\" value=\"Submit\" onclick=\"updateCourse(" + id + ");\" /></label></p><p><div id=\"modifyCourseMessage\" style=\"position:absolut;top:200px;left:300px;width:500px\"></div></p><p>&nbsp;</p></FIELDSET></form></div>";
				
		}
		
	if(element2=="class")
		{
			form = "<div id=\"add_class_form\" style=\"width:800px;\" ><form id=\"update_classroom_form\" name=\"update_classroom_form\" method=\"post\" action=\"\"><FIELDSET><LEGEND>ClassRoom form</LEGEND><label><br />Building:<input id=\"building\" type=\"text\" class=\"tfield\" size=\"5\"/></label><p><label>ClassRoom Number:<input id=\"number\" type=\"text\" class=\"tfield\" size=\"10\"/></label></p><p><label><input type=\"button\" name=\"Submit\" value=\"Submit\" onclick=\"updateClassroom("+id+");\" /></label></p><p><div id=\"modifyClassroomMessage\" style=\"position:absolut;top:200px;left:300px;width:500px\"></div></p><p>&nbsp;</p></FIELDSET></form></div>";
				
		}
	
	document.getElementById(element).innerHTML = form;
}